package org.learn.test;

public class HanoiTower {
    public static void main(String[] args) {
        Tower tower = new Tower();
        tower.move(5,'A','B','C');
    }
}
class Tower {
    public void move(int num, char a, char b, char c){
        //如果只有一个盘，num = 1
        if(num == 1){
            System.out.println(a + "->" + c);
        }else{
            //如果有多个盘，可以看成是两个，最下面的一个和上面的所个；
            //先借助c把上面所有盘移动到b
            move(num - 1,a,c,b);
            System.out.println(a + "->" + c);
            //再把b塔所有盘移动到c，借助a
            move(num - 1,b,a,c);
        }
    }
}
